package com.dufang.myarray;

import java.util.Arrays;

public class Demo02Arrays {
    public static void main(String[] args) {

        //按照格式打印数组元素 【元素1，元素2，。。。。】
        int[] arr={5,3,6,5,4,7};
        System.out.println(Arrays.toString(arr));

        //升序排序
        System.out.println("================");
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));

        //二分查找（前提是升序） 查找元素3
        System.out.println("=================");
        int[] arr1={1,2,3,4,5,6,7};
        int index=Arrays.binarySearch(arr1,3);
        System.out.println("index= "+index);

        //数组扩容
        System.out.println("==================");
        int[] arr2={1,2,3,4,5};
        int[] newArr=Arrays.copyOf(arr2,10);
        System.out.println(Arrays.toString(newArr));

        arr2=newArr;
        System.out.println(Arrays.toString(arr2));
    }


}
